/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.amuthu.indicator;

import org.amuthu.DataStore;
import org.amuthu.TalibMgr;

/**
 *
 * @author prabhu
 */
public class SAR extends Indicator
{
   private double acceleration;
   private double maximum;

   public SAR(DataStore dataStore, double acceleration, double maximum, int startOffset)
   {
      super(dataStore, startOffset);
      this.acceleration = acceleration;
      this.maximum = maximum;
   }

   @Override
   public double calculate()
   {
      int lastIdx = getLastIndex();

      TalibMgr.getTalib().sar(lastIdx,
                              lastIdx,
                              getDataStore().getHigh(),
                              getDataStore().getLow(),
                              acceleration,
                              maximum,
                              TalibMgr.getOutBeginIdx(),
                              TalibMgr.getOutNbElement(),
                              getResultArray());

      return getResultValue();
   }

   @Override
   public int getDayDependency()
   {
      return TalibMgr.getTalib().sarLookback(acceleration, maximum) +  startOffset;
   }
}
